import { getHomeRoute, getMenuByRouter } from '@/libs/util'
// routeHasExist， getTagNavListFromLocalstorage ， setTagNavListInLocalstorage
import { appRouter } from '@/router/routers'
export default {
  state: {
    tagNavList: [],
    homeRoute: getHomeRoute(appRouter),
    local: '',
    menuList: [],
    isFullScreen: false,
    menuCollapsed: false,
    shortcutMenu: [],
    workMenu: [],
    powerList: [],
    msg: {},
    current: '',
    msgList: []
  },
  getters: {
    menuList: (state, getters, rootState) => getMenuByRouter(appRouter, rootState.user.access)
    // menuList: state => state.menuList
  },
  mutations: {
    // setTagNavList (state, list) {
    //   if (list) {
    //     state.tagNavList = [...list]
    //     setTagNavListInLocalstorage([...list])
    //   } else state.tagNavList = getTagNavListFromLocalstorage()
    // },
    // addTag (state, { route, type = 'unshift' }) {
    //   if (!routeHasExist(state.tagNavList, route)) {
    //     if (type === 'push') state.tagNavList.push(route)
    //     else {
    //       if (route.name === 'home') state.tagNavList.unshift(route)
    //       else state.tagNavList.splice(1, 0, route)
    //     }
    //     setTagNavListInLocalstorage([...state.tagNavList])
    //   }
    // },
    setLocal (state, lang) {
      state.local = lang
    },
    setMsg (state, msg) {
      state.msg = msg
    },
    setCurrent (state, current) {
      state.current = current
    },
    setMsgList (state, msgList) {
      state.msgList = msgList
    }
  }
}
